import Vue from "vue";

function rename(str) {
  return str.charAt(0) + str.slice(1);
}

const requireModules = require.context("./", false, /\.js$/);

let modules = {};

requireModules.keys().forEach(fileName => {
  let config = requireModules(fileName);
  let apiName = rename(fileName.replace(/^\.\//, "").replace(/\.\w+$/, ""));
  modules[apiName] = config.default;
});

Object.keys(modules).forEach(name => {
  if (name !== "index") {
    Vue.use(modules[name]);
  }
});
